package com.struts.action;

import com.struts.business.JudgeAction;
import com.struts.service.Action;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Administrator on 2015/2/5.
 */
public class ActionServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String url="";
        String text = request.getParameter("text");

        System.out.println(text);

        Action action = new JudgeAction();//父类引用指向子类对象
       url= action.exexut(request,response);//接口回调



      //  request.setAttribute("lxd",text);


/*
        boolean b = isUserinfo(text);
        UserinfoVO userinfoVO = new UserinfoVO();
       String url="";
       if (b){

           userinfoVO.setU_name("success");
           userinfoVO.setU_pass("success");
           userinfoVO.setU_age("1");
       // request.setAttribute("meg","success");

//        RequestDispatcher requestDispatcher = request.getRequestDispatcher("/view/view.jsp");
//        requestDispatcher.forward(request,response);
           url="/view/view.jsp";
       }else {
           userinfoVO.setU_name("error");
           userinfoVO.setU_pass("error");
           userinfoVO.setU_age("0");
          // request.setAttribute("meg","error");
           url="/view/error.jsp";
//           RequestDispatcher requestDispatcher = request.getRequestDispatcher("/view/error.jsp");
//           requestDispatcher.forward(request,response);
       }
        request.setAttribute("meg",userinfoVO);*/
        RequestDispatcher requestDispatcher = request.getRequestDispatcher(url);
           requestDispatcher.forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }

   /* private  boolean isUserinfo(String userinfo){

        boolean b =false;

        if(userinfo.equals("lxd")){

            b = true;
        }
        return b;
    }*/

}
